<!DOCTYPE html>
<html lang="zh">

	<head>
		<meta charset="utf-8">
		<title>微信安全支付</title>
		<meta content="yes" name="apple-mobile-web-app-capable" />
		<meta content="yes" name="apple-touch-fullscreen" />
		<meta content="telephone=no,email=no" name="format-detection" />
		<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />

		<!-- 系统基本样式 -->
		<link type="text/css" rel="stylesheet" href="__CDN__/amazeui/2.3.0/css/amazeui.min.css" />
		

		<style type="text/css">
			html{
				font-size: 10px;
			}
			.header{
				background: #FFFFFF;
				margin-bottom: 15px;
			}
			.header{
				font-size: 16px;
				height: 40px;
			}
			
	  		
	
	  		.am-form label{
	  			font-size: 14px;padding-bottom: 20px;
	  		}
		</style>

	</head>

	<body>

		<div class="header">
			<div class="am-topbar am-topbar-default am-topbar-fixed-top">
				<a href="{:U('Shop/User/order')}"><i class="am-icon-chevron-left"></i>&nbsp;&nbsp;选择支付方式</a>
			</div>
		</div>
		
		<div class="am-padding-sm">
				<div class="am-text-center">
				合计<span class="am-text-danger">¥
					<span class="js_total_price" >{:round($total_fee/100.0,2)}元&nbsp;
						<if condition="$total_express gt 0">含运费：{:round($total_express/100,2)}元</if></span></span>
				</div>
				<form class="am-text-left am-form">
				    <div class="am-radio am-lg-text-left">
				      <label class="am-radio">
				        <input type="radio" name="payway" value="1" checked>
				        微信支付
				      </label>
				    </div>
				    
					<div class="am-radio am-lg-text-left">
				      <label class="am-radio">
				        <input type="radio" name="payway" value="2" >
				        货到付款
				      </label>
				    </div>
					
					<!--<ul class="am-list">
						<li >货到付款<i class="am-icon-check am-text-warning am-fr"></i></li>
						<li >微信支付<i class="am-icon-check am-text-warning am-fr"></i></li>
					</ul>-->
				</form>
				<div class="footer-menu am-text-right ">
					<a href="#" onclick="choose();"  class="am-btn am-btn-sm  am-block am-btn-danger">确定</a>
				</div>
		</div>
		<script type="text/javascript" src="__CDN__/jquery/2.1.1/jquery.min.js"></script>
		<script type="text/javascript">
			
			function choose(){
				var ele = document.querySelector("input:checked");
//				alert(ele.value);
				if(ele.value == "1"){
					callpay();
				}else{
					//货到付款
					var url = "{:U('Shop/OnlinePay/cashOndelivery')}";
					var ids = "{$ids}";
					$.ajax({
						url:url,
						type:'post',
						data:{id:ids},
					}).done(function(data){
						if(data.status){
							window.location.href = "{:U('Shop/User/order')}";
						}else{
							alert(data.info);
						}
					});
				}
			}
		</script>
		<script type="text/javascript">
		//调用微信JS api 支付
			function jsApiCall() {
				WeixinJSBridge.invoke(
					'getBrandWCPayRequest', 
					{$jsApiParameters},
					function(res) {
						if (res.err_msg == "get_brand_wcpay_request:ok") {
							window.location.href = "{:U('Shop/User/order')}";
						} else if (res.err_msg == "get_brand_wcpay_request:cancel") {
							alert("您取消了支付，可以在我的订单中继续支付！");
						} else if (res.err_msg == "get_brand_wcpay_request:fail") {
							alert(res.err_desc);
						}
					}
				);
			}

			function callpay() {
				if (typeof WeixinJSBridge == "undefined") {
					if (document.addEventListener) {
						document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
					} else if (document.attachEvent) {
						document.attachEvent('WeixinJSBridgeReady', jsApiCall);
						document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
					}
				} else {
					jsApiCall();
				}
			}
		</script>
		{__NORUNTIME__}
	</body>

</html>